package com.goodfox.web.biz.forest.service.impl;

import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.session.RowBounds;
import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.goodfox.web.biz.forest.entity.ForestRights;
import com.goodfox.web.biz.forest.entity.Woodland;
import com.goodfox.web.biz.forest.entity.WoodlandFour;
import com.goodfox.web.biz.forest.entity.WoodlandPhoto;
import com.goodfox.web.biz.forest.entity.WoodlandSpecies;
import com.goodfox.web.biz.forest.mapper.ForestRightsMapper;
import com.goodfox.web.biz.forest.mapper.WoodlandFourMapper;
import com.goodfox.web.biz.forest.mapper.WoodlandMapper;
import com.goodfox.web.biz.forest.service.ForestRightsService;
import com.goodfox.web.biz.forest.service.WoodlandService;
import com.goodfox.web.generic.area.entity.Area;
import com.goodfox.web.generic.area.mapper.AreaMapper;
import com.goodfox.web.generic.attribute.entity.Attribute;
import com.goodfox.web.generic.attribute.service.AttributeService;
import com.goodfox.web.generic.file.entity.FileEntity;
import com.goodfox.web.generic.file.entity.WebFormEntity;
import com.goodfox.web.generic.provide.annotation.NoteExplain;
import com.goodfox.web.generic.provide.entity.Pager;
import com.goodfox.web.generic.provide.util.AttributeUtil;
import com.goodfox.web.generic.provide.util.DateUtil;
import com.goodfox.web.generic.provide.util.ParameterUtil;
import com.goodfox.web.generic.provide.util.UUIDUtil;

@Transactional
@Service(value="forestRightsService")
@NoteExplain(comment="林权证管理")
public class ForestRightsServiceImpl implements ForestRightsService {

	/** log4j日志器 */
	private Logger logger=Logger.getLogger(ForestRightsServiceImpl.class);
	
	@Autowired
	private ForestRightsMapper forestRightsMapper;

	@Autowired
	private WoodlandMapper woodlandMapper;
	
	@Autowired
	private WoodlandService woodlandService;
	
	@Autowired
	private WoodlandFourMapper woodlandFourMapper;
	
	@Autowired
	private AreaMapper areaMapper;
	
	@Autowired
	private AttributeService attributeService;

	@NoteExplain(comment="查询林权证分页列表")
	public Pager<ForestRights> queryForestRightsPager(int currentPage,int numPerPage,Map map){
		int start=(currentPage-1)*numPerPage;
		Long allCount=forestRightsMapper.selectForestRightsListCount(map);
		List<ForestRights> list=forestRightsMapper.selectForestRightsList(map, new RowBounds(start,numPerPage));
		if(list!=null){
			for(ForestRights forestRights:list){
				map.put("fstRigId", forestRights.getFstRigId());
				forestRights.setRsWoodlandList(woodlandMapper.selectWoodlandList(map));
				if(forestRights.getRsWoodlandList()==null){
					forestRights.setRsWoodlandList(new ArrayList<Woodland>());
					forestRights.getRsWoodlandList().add(new Woodland());
				}else{
					for(Woodland woodland:forestRights.getRsWoodlandList()){
						woodland.setAlWoodlandSpeciesList(woodlandService.queryWoodlandSpeciesList(woodland.getWoodId()));
					}
				}
			}
		}
		return new Pager<ForestRights>(allCount, list);
	}
	
	@NoteExplain(comment="查询林权证简单汇总")
	public Map queryForestRightsSimpleSummary(Map map){
		return forestRightsMapper.selectForestRightsSimpleSummary(map);
	}
	
	@NoteExplain(comment="获取林权证")
	public ForestRights getForestRights(String fstRigId){
		ForestRights forestRights=forestRightsMapper.selectForestRightsById(fstRigId);
		logger.debug("forestRights:"+forestRights);
		forestRights.setAlWoodlandList(queryWoodlandList(fstRigId));
		return forestRights;
	}
	
	@NoteExplain(comment="新增林权证",paraDesc="entity 新增实体;loginLogId 登录日志Id")
	public void addForestRights(ForestRights entity,String loginLogId){
		if(ParameterUtil.judgeInteger(entity.getRigNumber())){
			entity.setSort(Long.parseLong(entity.getRigNumber()));
		}
		forestRightsMapper.insertForestRights(entity);
		if(entity.getRsWoodlandList()!=null){
			for(Woodland woodland:entity.getRsWoodlandList()){
				woodland.setFstRigId(entity.getFstRigId());
				addWoodland(woodland,loginLogId);
			}
		}
	}
	
	@NoteExplain(comment="更新林权证",paraDesc="oldEny 旧实体;newEny 新实体;loginLogId 登录日志Id")
	public void modifyForestRights(ForestRights oldEny,ForestRights newEny,String loginLogId){
		if(ParameterUtil.judgeInteger(newEny.getRigNumber())){
			newEny.setSort(Long.parseLong(newEny.getRigNumber()));
		}
		if(oldEny.getAlWoodlandList()!=null){
			for(Woodland woodland:oldEny.getAlWoodlandList()){
				removeWoodland(woodland,loginLogId);
			}
		}
		forestRightsMapper.updateForestRights(newEny);
		if(newEny.getRsWoodlandList()!=null){
			for(Woodland woodland:newEny.getRsWoodlandList()){
				woodland.setFstRigId(newEny.getFstRigId());
				addWoodland(woodland,loginLogId);
			}
		}
    	List<Woodland> woodlandList=queryWoodlandList(newEny.getFstRigId());
    	if(woodlandList==null || woodlandList.size()==0){
    		removeForestRights(getForestRights(newEny.getFstRigId()), loginLogId);
    	}
	}
	
	@NoteExplain(comment="移除林权证",paraDesc="entity 新增实体;loginLogId 登录日志Id")
	public void removeForestRights(ForestRights entity,String loginLogId){
		if(entity.getAlWoodlandList()!=null){
			for(Woodland woodland:entity.getAlWoodlandList()){
				removeWoodland(woodland,loginLogId);
			}
		}
		forestRightsMapper.deleteForestRightsById(entity.getFstRigId());
	}

	@NoteExplain(comment="查询林地列表")
	public List<Woodland> queryWoodlandList(String fstRigId){
		Map map=new HashMap();
		map.put("fstRigId", fstRigId);
		List<Woodland> woodlandList=woodlandMapper.selectWoodlandList(map);
		if(woodlandList!=null){
			for(Woodland woodland:woodlandList){
				woodland.setAlWoodlandFourList(woodlandService.queryWoodlandFourList(woodland.getWoodId()));
				woodland.setAlWoodlandPhotoList(woodlandService.queryWoodlandPhotoList(woodland.getWoodId()));
				woodland.setAlWoodlandSpeciesList(woodlandService.queryWoodlandSpeciesList(woodland.getWoodId()));
			}
		}
		return woodlandList;
	}
	
	@NoteExplain(comment="新增林地",paraDesc="entity 新增实体;loginLogId 登录日志Id")
	public void addWoodland(Woodland entity,String loginLogId){
		woodlandMapper.insertWoodland(entity);
		if(entity.getAlWoodlandFourList()!=null){
			for(WoodlandFour woodlandFour:entity.getAlWoodlandFourList()){
				woodlandFour.setWoodId(entity.getWoodId());
				woodlandService.addWoodlandFour(woodlandFour, loginLogId);
			}
		}
		if(entity.getAlWoodlandPhotoList()!=null){
			for(WoodlandPhoto woodlandPhoto:entity.getAlWoodlandPhotoList()){
				woodlandPhoto.setWoodId(entity.getWoodId());
				woodlandService.addWoodlandPhoto(woodlandPhoto, loginLogId);
			}
		}
		if(entity.getAlWoodlandSpeciesList()!=null){
			for(WoodlandSpecies woodlandSpecies:entity.getAlWoodlandSpeciesList()){
				woodlandSpecies.setWoodId(entity.getWoodId());
				woodlandService.addWoodlandSpecies(woodlandSpecies, loginLogId);
			}
		}
	}
	
	@NoteExplain(comment="更新林地",paraDesc="oldEny 旧实体;newEny 新实体;loginLogId 登录日志Id")
	public void modifyWoodland(Woodland oldEny,Woodland newEny,String loginLogId){
		if(oldEny.getAlWoodlandFourList()!=null){
			for(WoodlandFour woodlandFour:oldEny.getAlWoodlandFourList()){
				woodlandService.removeWoodlandFour(woodlandFour, loginLogId);
			}
		}
		if(oldEny.getAlWoodlandPhotoList()!=null){
			for(WoodlandPhoto woodlandPhoto:oldEny.getAlWoodlandPhotoList()){
				woodlandService.removeWoodlandPhoto(woodlandPhoto, loginLogId);
			}
		}
		if(oldEny.getAlWoodlandSpeciesList()!=null){
			for(WoodlandSpecies woodlandSpecies:oldEny.getAlWoodlandSpeciesList()){
				woodlandService.removeWoodlandSpecies(woodlandSpecies, loginLogId);
			}
		}
		woodlandMapper.updateWoodland(newEny);
		if(newEny.getAlWoodlandFourList()!=null){
			for(WoodlandFour woodlandFour:newEny.getAlWoodlandFourList()){
				woodlandFour.setWoodId(newEny.getWoodId());
				woodlandService.addWoodlandFour(woodlandFour, loginLogId);
			}
		}
		if(newEny.getAlWoodlandPhotoList()!=null){
			for(WoodlandPhoto woodlandPhoto:newEny.getAlWoodlandPhotoList()){
				woodlandPhoto.setWoodId(newEny.getWoodId());
				woodlandService.addWoodlandPhoto(woodlandPhoto, loginLogId);
			}
		}
		if(newEny.getAlWoodlandSpeciesList()!=null){
			for(WoodlandSpecies woodlandSpecies:newEny.getAlWoodlandSpeciesList()){
				woodlandSpecies.setWoodId(newEny.getWoodId());
				woodlandService.addWoodlandSpecies(woodlandSpecies, loginLogId);
			}
		}
	}
	
	@NoteExplain(comment="移除林地",paraDesc="entity 新增实体;loginLogId 登录日志Id")
	public void removeWoodland(Woodland entity,String loginLogId){
		if(entity.getAlWoodlandFourList()!=null){
			for(WoodlandFour woodlandFour:entity.getAlWoodlandFourList()){
				woodlandService.removeWoodlandFour(woodlandFour, loginLogId);
			}
		}
		if(entity.getAlWoodlandPhotoList()!=null){
			for(WoodlandPhoto woodlandPhoto:entity.getAlWoodlandPhotoList()){
				woodlandService.removeWoodlandPhoto(woodlandPhoto, loginLogId);
			}
		}
		if(entity.getAlWoodlandSpeciesList()!=null){
			for(WoodlandSpecies woodlandSpecies:entity.getAlWoodlandSpeciesList()){
				woodlandService.removeWoodlandSpecies(woodlandSpecies, loginLogId);
			}
		}
		woodlandMapper.deleteWoodlandById(entity.getWoodId());
	}

	@NoteExplain(comment="获取林地")
	public Woodland getWoodland(String woodId){
		Woodland woodland=woodlandMapper.selectWoodlandById(woodId);
		if(woodland!=null){
			woodland.setAlWoodlandFourList(woodlandService.queryWoodlandFourList(woodland.getWoodId()));
			woodland.setAlWoodlandPhotoList(woodlandService.queryWoodlandPhotoList(woodland.getWoodId()));
			woodland.setAlWoodlandSpeciesList(woodlandService.queryWoodlandSpeciesList(woodland.getWoodId()));
		}
		return woodland;
	}
	
	@NoteExplain(comment="导入林权证")
	public Map importForestRights(WebFormEntity webFormEntity,String loginLogId){
		Map map=new HashMap();
		int rightsCount=0;
		int woodCount=0;
		int fourCount=0;
		if(webFormEntity.getFileEntitys().size()==1){
			FileEntity fileEntity=webFormEntity.getFileEntitys().get(0);
			int index=1;
			try{
				POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream(fileEntity.getRealPath()));
				HSSFWorkbook workbook=new HSSFWorkbook(fs);
				HSSFSheet sheet=workbook.getSheet("Sheet1");
				ForestRights rights=null;
				Woodland wood=null;
				while(true){
					HSSFRow row = sheet.getRow(index);
					if(row!=null && row.getCell(38)!=null && row.getCell(38).getCellType()==HSSFCell.CELL_TYPE_STRING && !row.getCell(38).getStringCellValue().trim().equals("")){
						String rigCode=ParameterUtil.getCellValue(row.getCell(0), String.class);
						if(rigCode!=null){
							if(rights!=null){
								if(rigCode.equals(rights.getRigCode())){
									String appNumber=ParameterUtil.getCellValue(row.getCell(6), String.class);
									if(appNumber!=null){
										wood=importAddWoodland(row, rights.getRigCode(), loginLogId);
										woodCount++;
										importAddWoodlandFour(row, wood.getAppNumber(), loginLogId);
										fourCount++;
									}
								}else{
									rights=importAddForestRights(row, loginLogId);
									rightsCount++;
									wood=importAddWoodland(row, rights.getRigCode(), loginLogId);
									woodCount++;
									importAddWoodlandFour(row, wood.getAppNumber(), loginLogId);
									fourCount++;
								}
							}else{
								rights=importAddForestRights(row, loginLogId);
								rightsCount++;
								wood=importAddWoodland(row, rights.getRigCode(), loginLogId);
								woodCount++;
								importAddWoodlandFour(row, wood.getAppNumber(), loginLogId);
								fourCount++;
							}
						}else{
							if(wood!=null){
								importAddWoodlandFour(row, wood.getAppNumber(), loginLogId);
								fourCount++;
							}
						}
						index++;
					}else{
						break;
					}
				}
			}catch(Exception ex){
				logger.error("导入林权证异常:["+index+"]",ex);
			}
		}
		map.put("rightsCount", rightsCount);
		map.put("woodCount", woodCount);
		map.put("fourCount", fourCount);
		return map;
	}
	
	private ForestRights importAddForestRights(HSSFRow row,String loginLogId){
		ForestRights rights=new ForestRights();
		rights.setFstRigId(UUIDUtil.getUUID());
		rights.setRigCode(ParameterUtil.getCellValue(row.getCell(0), String.class));
		rights.setRigNumber(ParameterUtil.getCellValue(row.getCell(1), String.class));
		rights.setUnit(ParameterUtil.getCellValue(row.getCell(2), String.class));
		rights.setLegal(ParameterUtil.getCellValue(row.getCell(3), String.class));
		rights.setIdCards(ParameterUtil.getCellValue(row.getCell(4), String.class));
		rights.setAddress(ParameterUtil.getCellValue(row.getCell(5), String.class));
		if(forestRightsMapper.selectForestRightsCountByCode(rights.getRigCode())==0){
			addForestRights(rights, loginLogId);
		}
		return rights;
	}
	
	private Woodland importAddWoodland(HSSFRow row,String rigCode,String loginLogId){
		Woodland wood=new Woodland();
		wood.setWoodId(UUIDUtil.getUUID());
		wood.setFstRigId(forestRightsMapper.selectFstRigIdByCode(rigCode));
		wood.setAppNumber(ParameterUtil.getCellValue(row.getCell(6), String.class));
		String rstType=ParameterUtil.getCellValue(row.getCell(7), String.class);
		if(rstType!=null){
			Attribute attribute=AttributeUtil.getAttribute("登记类型",rstType);
			if(attribute==null){
				attribute=AttributeUtil.getAttribute("登记类型","初始");
				attribute.setAtrId(UUIDUtil.getUUID());
				attribute.setAtrName(rstType);
				attributeService.addAttribute(attribute, loginLogId);
			}
			wood.setRstType(attribute.getAtrValue());
		}
		wood.setMortgage(ParameterUtil.getCellValue(row.getCell(8), String.class).equals("是")?"1":"0");
		wood.setBackForest(ParameterUtil.getCellValue(row.getCell(9), String.class).equals("是")?"1":"0");
		String fstOwn=ParameterUtil.getCellValue(row.getCell(10), String.class);
		if(fstOwn!=null){
			Attribute attribute=AttributeUtil.getAttribute("林地所有权权利人",fstOwn);
			if(attribute==null){
				attribute=AttributeUtil.getAttribute("林地所有权权利人","国家");
				attribute.setAtrId(UUIDUtil.getUUID());
				attribute.setAtrName(fstOwn);
				attributeService.addAttribute(attribute, loginLogId);
			}
			wood.setFstOwn(attribute.getAtrValue());
		}
		wood.setFstUse(ParameterUtil.getCellValue(row.getCell(11), String.class));
		wood.setWoodOwn(ParameterUtil.getCellValue(row.getCell(12), String.class));
		wood.setWoodUse(ParameterUtil.getCellValue(row.getCell(13), String.class));
		wood.setSmallTo(ParameterUtil.getCellValue(row.getCell(15), String.class));
		wood.setFstClass(ParameterUtil.getCellValue(row.getCell(16), String.class));
		wood.setSmallCls(ParameterUtil.getCellValue(row.getCell(17), String.class));
		String acreage=ParameterUtil.getCellValue(row.getCell(18), Double.class);
		wood.setAcreage(acreage==null?null:Double.valueOf(acreage));
		String treesNum=ParameterUtil.getCellValue(row.getCell(20), Long.class);
		wood.setTreesNum(treesNum==null?null:Long.valueOf(treesNum));
		wood.setAffDate(DateUtil.dateFormat(ParameterUtil.getCellValue(row.getCell(21), Long.class), "yyyy"));
		String landType=ParameterUtil.getCellValue(row.getCell(22), String.class);
		if(landType!=null){
			Attribute attribute=AttributeUtil.getAttribute("地类",landType);
			if(attribute==null){
				attribute=AttributeUtil.getAttribute("地类","有林地");
				attribute.setAtrId(UUIDUtil.getUUID());
				attribute.setAtrName(landType);
				attributeService.addAttribute(attribute, loginLogId);
			}
			wood.setLandType(attribute.getAtrValue());
		}
		String fstType=ParameterUtil.getCellValue(row.getCell(23), String.class);
		if(fstType!=null){
			Attribute attribute=AttributeUtil.getAttribute("森林分类",fstType);
			if(attribute==null){
				attribute=AttributeUtil.getAttribute("森林分类","重点公益林");
				attribute.setAtrId(UUIDUtil.getUUID());
				attribute.setAtrName(fstType);
				attributeService.addAttribute(attribute, loginLogId);
			}
			wood.setFstType(attribute.getAtrValue());
		}
		String fstSpecies=ParameterUtil.getCellValue(row.getCell(24), String.class);
		if(fstSpecies!=null){
			Attribute attribute=AttributeUtil.getAttribute("林种",fstSpecies);
			if(attribute==null){
				attribute=AttributeUtil.getAttribute("林种","生态林");
				attribute.setAtrId(UUIDUtil.getUUID());
				attribute.setAtrName(fstSpecies);
				attributeService.addAttribute(attribute, loginLogId);
			}
			wood.setFstSpecies(attribute.getAtrValue());
		}
		String fstUseDate=ParameterUtil.getCellValue(row.getCell(25), Long.class);
		wood.setFstUseDate(fstUseDate==null?null:Long.valueOf(fstUseDate));
		wood.setEndDate(DateUtil.dateFormat(ParameterUtil.getCellValue(row.getCell(26), String.class), "yyyy.MM.dd"));
		wood.setSlope(ParameterUtil.getCellValue(row.getCell(27), String.class));
		wood.setAspect(ParameterUtil.getCellValue(row.getCell(28), String.class));
		wood.setCabinetNum(ParameterUtil.getCellValue(row.getCell(29), String.class));
		wood.setBasis(ParameterUtil.getCellValue(row.getCell(30), String.class));
		wood.setExplain(ParameterUtil.getCellValue(row.getCell(31), String.class));
		wood.setNote(ParameterUtil.getCellValue(row.getCell(32), String.class));
		wood.setInvPerson(ParameterUtil.getCellValue(row.getCell(33), String.class));
		wood.setHdePerson(ParameterUtil.getCellValue(row.getCell(34), String.class));
		wood.setCrgPerson(ParameterUtil.getCellValue(row.getCell(35), String.class));
		String issueDate=ParameterUtil.getCellValue(row.getCell(36), String.class);
		if(issueDate!=null){
			if(issueDate.length()==4){
				issueDate=issueDate+".04.20";
			}else if(issueDate.length()==7){
				issueDate=issueDate+".20";
			}
		}
		wood.setIssueDate(DateUtil.dateFormat(issueDate, "yyyy.MM.dd"));
		Area area=areaMapper.selectAreaByName(ParameterUtil.getCellValue(row.getCell(14), String.class));
		wood.setAreaId(area==null?"":area.getAreaId());
		if(woodlandMapper.selectWoodlandCountByNumber(wood.getAppNumber())==0){
			addWoodland(wood, loginLogId);
			String species=ParameterUtil.getCellValue(row.getCell(19), String.class);
			if(species!=null){
				List<WoodlandSpecies> alWoodlandSpeciesList=new ArrayList<WoodlandSpecies>();
				List<String> speciesList=ParameterUtil.getListForString(species, "、");
				for(String atrValue:speciesList){
					Attribute attribute=AttributeUtil.getAttribute("主要树种",atrValue);
					if(attribute==null){
						attribute=AttributeUtil.getAttribute("主要树种","落叶松");
						attribute.setAtrId(UUIDUtil.getUUID());
						attribute.setAtrName(atrValue);
						attributeService.addAttribute(attribute, loginLogId);
					}
					WoodlandSpecies woodSpecies=new WoodlandSpecies();
					woodSpecies.setSpeciesId(UUIDUtil.getUUID());
					woodSpecies.setAtrId(attribute.getAtrId());
					woodSpecies.setWoodId(wood.getWoodId());
					woodlandService.addWoodlandSpecies(woodSpecies, loginLogId);
					alWoodlandSpeciesList.add(woodSpecies);
				}
				wood.setAlWoodlandSpeciesList(alWoodlandSpeciesList);
			}
		}
		return wood;
	}
	
	private void importAddWoodlandFour(HSSFRow row,String appNumber,String loginLogId){
		WoodlandFour four=new WoodlandFour();
		four.setFourId(UUIDUtil.getUUID());
		four.setWoodId(woodlandMapper.selectWoodIdByNumber(appNumber));
		four.setFourName(ParameterUtil.getCellValue(row.getCell(37), String.class));
		String corXY=ParameterUtil.getCellValue(row.getCell(38), String.class);
		if(corXY.indexOf("：")>=0){
			corXY=corXY.substring(corXY.indexOf("：")+1);
		}
		four.setCorXY(corXY);
		Map map=new HashMap();
		map.put("woodId", four.getWoodId());
		map.put("fourName", four.getFourName());
		if(woodlandFourMapper.selectWoodlandFourCountByWoodIdAndName(map)==0){
			woodlandService.addWoodlandFour(four, loginLogId);
		}
	}

	@NoteExplain(comment="导出林权证列表")
	public List<ForestRights> exportForestRightsList(HttpServletRequest request, HttpServletResponse response,Map map){
		List<ForestRights> list=forestRightsMapper.selectForestRightsList(map);
		if(list!=null){
			for(ForestRights forestRights:list){
				map.put("fstRigId", forestRights.getFstRigId());
				forestRights.setRsWoodlandList(woodlandMapper.selectWoodlandList(map));
				for(Woodland woodland:forestRights.getRsWoodlandList()){
					woodland.setAlWoodlandFourList(woodlandService.queryWoodlandFourList(woodland.getWoodId()));
					woodland.setAlWoodlandSpeciesList(woodlandService.queryWoodlandSpeciesList(woodland.getWoodId()));
					if(woodland.getSpeciesTxt()==null || woodland.getSpeciesTxt().equals("")){
						String speciesTxt="";
						if(woodland.getAlWoodlandSpeciesList()!=null){
							for(WoodlandSpecies species:woodland.getAlWoodlandSpeciesList()){
								speciesTxt+=species.getAtrName()+"、";
							}
							woodland.setSpeciesTxt(speciesTxt.substring(0,speciesTxt.length()-1));
						}
					}
				}
			}
		}
		return list;
	}

}
